package app.beit.finportal.service.convert;

import java.util.ArrayList;
import java.util.List;

import app.beit.finportal.bean.RelativeWebProgramsBean;
import app.beit.finportal.entity.RelativeWebPrograms;
import app.beit.finportal.utils.StringUtils;

public class RelativeWebProgramsConvert {

	/**
	 * Convert Entity To Bean
	 * @param entity
	 * @return RelativeWebProgramsBean
	 */
	public static RelativeWebProgramsBean entityToBean(final RelativeWebPrograms entity){
		final RelativeWebProgramsBean bean = new RelativeWebProgramsBean();
		
		bean.setId(entity.getId());
		bean.setCreatedBy(StringUtils.nullToEmpty(entity.getCreatedBy()));
		bean.setCreatedDate(entity.getCreatedDate());
		bean.setUpdatedBy(StringUtils.nullToEmpty(entity.getUpdatedBy()));
		bean.setUpdatedDate(entity.getUpdatedDate());
		bean.setDescription(StringUtils.nullToEmpty(entity.getDescription()));
		bean.setName(StringUtils.nullToEmpty(entity.getName()));
		bean.setTypes(StringUtils.nullToEmpty(entity.getTypes()));
		bean.setUrl(StringUtils.nullToEmpty(entity.getUrl()));
		bean.setStatus(entity.getStatus());
		
		return bean;
	}
	
	/**
	 * Convert Bean to Entity
	 * @param bean
	 * @return RelativeWebPrograms
	 */
	public static RelativeWebPrograms beanToEntity(final RelativeWebProgramsBean bean){
		final RelativeWebPrograms entity = new RelativeWebPrograms();

		entity.setId(bean.getId());
		entity.setCreatedBy(StringUtils.nullToEmpty(bean.getCreatedBy()));
		entity.setCreatedDate(bean.getCreatedDate());
		entity.setUpdatedBy(StringUtils.nullToEmpty(bean.getUpdatedBy()));
		entity.setUpdatedDate(bean.getUpdatedDate());
		entity.setDescription(StringUtils.nullToEmpty(bean.getDescription()));
		entity.setName(StringUtils.nullToEmpty(bean.getName()));
		entity.setTypes(StringUtils.nullToEmpty(bean.getTypes()));
		entity.setUrl(StringUtils.nullToEmpty(bean.getUrl()));
		entity.setStatus(bean.getStatus());
		
		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * @param entities
	 * @return List RelativeWebProgramsBean
	 */
	public static List<RelativeWebProgramsBean> entityToBean(final List<RelativeWebPrograms> entities){
		final List<RelativeWebProgramsBean> beans = new ArrayList<RelativeWebProgramsBean>();
		
		for(final RelativeWebPrograms entity : entities){
			beans.add(RelativeWebProgramsConvert.entityToBean(entity));
		}
		
		return beans;
	}
	
	/**
	 * Convert List Bean to List Entity
	 * @param beans
	 * @return List RelativeWebPrograms
	 */
	public static List<RelativeWebPrograms> beanToEntity(final List<RelativeWebProgramsBean> beans){
		final List<RelativeWebPrograms> entities = new ArrayList<RelativeWebPrograms>();
		
		for(final RelativeWebProgramsBean bean : beans){
			entities.add(RelativeWebProgramsConvert.beanToEntity(bean));
		}
		
		return entities;
	}
	
}
